
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.freedom.sql.jdbc.request.ShowCreateTable;
import com.freedom.sql.jdbc.utils.LoggerUtils;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;

public class NettyClient {
	private static final Logger logger = LogManager.getLogger(NettyClient.class);

	public static void main(String[] args) throws InterruptedException {
		// 基于netty client
		io.netty.channel.socket.nio.NioSocketChannel ch;
		EventLoopGroup group = new NioEventLoopGroup();
		try {
			Bootstrap b = new Bootstrap();
			b.group(group).channel(NioSocketChannel.class).option(ChannelOption.TCP_NODELAY, true)
					.handler(new ChannelInitializer<SocketChannel>() {
						@Override
						protected void initChannel(SocketChannel ch) throws Exception {
							// TODO Auto-generated method stub
							LoggerUtils.debug(logger, "channel is:" + ch.getClass().toGenericString());
						}
					});
			ChannelFuture f = b.connect("172.17.0.246", 3306).sync();
			f.channel().closeFuture().sync();
		} finally {
			group.shutdownGracefully();
		}
	}
}
